package com.expdatacloud.controller.report.charts;

import com.expdatacloud.dto.ApiResponse;
import com.expdatacloud.service.ReportsService;
import com.expdatacloud.vo.SuppliedMaterialsCheckMonthReportVo;
import com.expdatacloud.vo.SuppliedMaterialsCheckWeekReportVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jie
 * @date 2019/12/30 -15:24
 */
@RequestMapping("/charts")
@RestController
public class ChartsController {

    @Autowired
    private ReportsService reportsService;

    /**
     * IQC来料周报表
     */
    @GetMapping("/suppliedMaterialsCheckWeekReportList")
    public ApiResponse suppliedMaterialsCheckWeekReportList(HttpSession session) {


        Map<String, Object> map = new HashMap<>();
        List<SuppliedMaterialsCheckWeekReportVo> suppliedMaterialsCheckWeekReportVoList = (List<SuppliedMaterialsCheckWeekReportVo>) session.getAttribute("suppliedMaterialsCheckWeekReportList");
        List<String> weekList = (List<String>) session.getAttribute("weekList");
        map.put("suppliedMaterialsCheckWeekReportVoList", suppliedMaterialsCheckWeekReportVoList);
        map.put("weekList", weekList);
        return ApiResponse.ok(map);
    }

    /**
     * IQC来料月报表
     */
    @GetMapping("/suppliedMaterialsCheckMonthReportList")
    public ApiResponse suppliedMaterialsCheckMonthReportList(HttpSession session) {


        Map<String, Object> map = new HashMap<>();
        List<SuppliedMaterialsCheckMonthReportVo> suppliedMaterialsCheckMonthReportVoList = (List<SuppliedMaterialsCheckMonthReportVo>) session.getAttribute("suppliedMaterialsCheckMonthReportVo");
        List<String> monthList = (List<String>) session.getAttribute("monthList");
        map.put("suppliedMaterialsCheckMonthReportVoList", suppliedMaterialsCheckMonthReportVoList);
        map.put("monthList", monthList);
        return ApiResponse.ok(map);
    }
    /**
     * IQC来料周报表（物料大类）
     */
    @GetMapping("/suppliedMaterialsCheckWeekByUdf8ReportList")
    public ApiResponse suppliedMaterialsCheckWeekByUdf8ReportList(HttpSession session) {


        Map<String, Object> map = new HashMap<>();
        List<SuppliedMaterialsCheckWeekReportVo> suppliedMaterialsCheckMonthReportVoList = (List<SuppliedMaterialsCheckWeekReportVo>) session.getAttribute("suppliedMaterialsCheckWeekReportList");
        List<Integer> weekList = ( List<Integer>) session.getAttribute("weekList");
        map.put("suppliedMaterialsCheckMonthReportVoList", suppliedMaterialsCheckMonthReportVoList);
        map.put("weekList", weekList);
        return ApiResponse.ok(map);
    }

    /**
     * 物料大类饼状图
     */
    @GetMapping("/toInspectionWeekByUdf8Chart2")
    public ApiResponse toInspectionWeekByUdf8Chart2(String startTime, String endTime,String shipper) throws ParseException {
        Map<String, Object> map = reportsService.suppliedMaterialsCheckWeekByUDF8ReportList(startTime, endTime, null,shipper);
        return ApiResponse.ok(map);
    }
}
